<template>
    <div style="height: 65px;line-height: 50px;display: flex;
        background-color: #545c64">
        <div style="width: 200px;padding-left: 30px;
        padding-top: 10px;
        font-weight: bold;color: cornflowerblue;font-size: 26px;background-color: #545c64"><a href="/">蜀行网后台</a></div>
        <div style="flex: 1"></div>
        <div style="width: 100px">
            <el-dropdown>
          <span class="el-dropdown-link" style="color: white;font-size: 15px">
<!--              <el-avatar :size="50" :src="user.image" style="position: relative; top: 10px"></el-avatar>-->
              {{user.nickName}}你好！
              <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item @click="check">个人信息</el-dropdown-item>
                        <el-dropdown-item @click="logout">退出系统</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
    export default {
        name: "Header.vue",
        data() {
            return {
                user: {},
            }
        },
        methods: {
            logout() {
                window.sessionStorage.clear();
                this.$router.push('/login')
                this.$message({
                    type: "success",
                    message: "退出登录成功！"
                })
            },
            check() {
                this.$router.push('/person')
            }
        },
        created() {
            let str = sessionStorage.getItem("user") || "{}"
            this.user = JSON.parse(str)
        }
    }
</script>

<style scoped>
    a {
        text-decoration: none;
        color: cornflowerblue;
    }
</style>
